package com.example.springmaven.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Author lep
 * @Date 2023/10/25 16:54
 */
@RestController
@RequestMapping(value = "/test")
@Slf4j
public class TestController {

    @GetMapping("/test")
    public String test() {
        log.info("我是 版本 v0.0.3");
        return "this v0.0.3";
    }

    @GetMapping("/test2")
    public String test2() {
        /**
         * 获取地址(服务器的内网地址)(内网ip)
         *
         * @return
         */
        InetAddress localHost = null;
        try {
            localHost = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        log.info("我是 版本 v0.0.3 {}", localHost.getHostAddress());
        return "this v0.0.3 :" + localHost.getHostAddress();
    }

}
